﻿using System;

namespace QAToolsAddin.Comparer {
    partial class Compare {
        struct HashRow {
            public int Row;
            public string Key;
            public UInt32 Hash;
            public int LinkedRow;

            public bool IsNull {
                get { return Hash == 0; }
            }

            public bool IsNotNull {
                get { return Hash != 0; }
            }

            public static bool operator <(HashRow a, HashRow b) {
                return a.Hash < b.Hash;
            }

            public static bool operator >(HashRow a, HashRow b) {
                return a.Hash > b.Hash;
            }

            public static bool operator ==(HashRow a, HashRow b) {
                return a.Hash == b.Hash && string.CompareOrdinal(a.Key, b.Key) == 0;
            }

            public static bool operator !=(HashRow a, HashRow b) {
                return a.Hash != b.Hash || string.CompareOrdinal(a.Key, b.Key) != 0;
            }

            public override bool Equals(Object o) {
                return o is HashRow && Hash == ((HashRow)o).Hash && string.CompareOrdinal(Key, ((HashRow)o).Key) != 0;
            }

            public override int GetHashCode() {
                return (int)Hash;
            }
        }

    }
}
